package me.pcqpcq.android.tvlauncher.helper;

import android.os.Environment;
import me.pcqpcq.android.tvlauncher.app.TVApplication;

import java.io.File;

/**
 *
 * Helper of current project
 * @author pcqpcq
 * @version 1.0.0
 * @since 13-10-31 下午8:00
 */
public class ProjectHelper {

    /**
     * <p> 取得基本的缓存路径(无SD卡则使用RAM)
     *
     * @return 类似这样的路径 /mnt/sdcard/Android/data/demo.android/cache/ 或者 /data/data/demo.android/cache/
     */
    public static String getBaseCachePath() {
        String result = null;
        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                && Environment.getExternalStorageDirectory().canWrite()) {
            result = TVApplication.getInstance().getExternalCacheDir().getAbsolutePath().concat(File.separator);
        }
        if (result == null || "".equals(result)) {
            result = TVApplication.getInstance().getCacheDir().getPath().concat(File.separator);
        }
        return result;
    }

}
